package com.hengxinguotong.zhihuichengjian.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.hengxinguotong.zhihuichengjian.R;
import com.hengxinguotong.zhihuichengjian.bean.LegendBean;
import com.hengxinguotong.zhihuichengjian.treeview.RecyclerAdapter;
import com.hengxinguotong.zhihuichengjian.widget.font.HXTextView;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * @CopyRight 恒信国通信息科技
 * @Author WuLei
 * @Date 2018/11/9
 */

public class LegendAdapter extends RecyclerAdapter<LegendBean, LegendAdapter.LegendViewHolder> {

    public LegendAdapter(Context context, List<LegendBean> dataList) {
        super(context, dataList);
    }

    @Override
    public LegendViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = View.inflate(context, R.layout.item_legend, null);
        return new LegendViewHolder(view);
    }

    @Override
    public void onBindViewHolder(LegendViewHolder holder, int position) {
        holder.bindData(position);
    }

    public class LegendViewHolder extends RecyclerAdapter.BaseViewHolder
    {
        @BindView(R.id.legend_img)
        ImageView legendImg;
        @BindView(R.id.legend_tv)
        HXTextView legendTv;

        public LegendViewHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }

        @Override
        public void bindData(int position) {
            LegendBean legendBean = dataList.get(position);
            legendImg.setImageResource(legendBean.getDrawableId());
            legendTv.setText(legendBean.getLegendName());
        }
    }
}
